Enriches the lambda
crate with http
types targeting AWS ALB, API Gateway REST and HTTP API lambda integrations.
This crate abstracts over all of these trigger events using standard http
types minimizing the mental overhead
of understanding the nuances and variation between trigger details allowing you to focus more on your application while also giving you to the maximum flexibility to
transparently use whichever lambda trigger suits your application and cost optimiztions best.
Examples
Hello World
lambda_http
handlers adapt to the standard lambda::Handler
interface using the handler
function.
The simplest case of an http handler is a function of an http::Request
to a type that can be lifted into an http::Response
.
You can learn more about these types here.
Adding an #[lambda(http)]
attribute to a #[tokio::run]
-decorated main
function will setup and run the Lambda function.
Note: this comes at the expense of any onetime initialization your lambda task might find value in.
The full body of your main
function will be executed on every invocation of your lambda task.
use ;
type Error = ;
async
Hello World, Without Macros
For cases where your lambda might benfit from one time function initializiation might
prefer a plain main
function and invoke netlify_lambda::run
explicitly in combination with the handler
function.
Depending on the runtime cost of your dependency bootstrapping, this can reduce the overall latency of your functions execution path.
use ;
type Error = ;
async
Leveraging trigger provided data
You can also access information provided directly from the underlying trigger events, like query string parameters,
with the RequestExt
trait.
use ;
type Error = ;
async
async